# -*- coding: utf-8 -*-
# @Time         : 2021/8/16 15:14
# @Author       : Jinxing Lin
# @StudentNumber: 20216523
# @Affiliation  : SUN YAT-SEN UNIVERSITY  SCHOOL OF SYSTEMS SCIENCE AND ENGINEERING
# @Mail         ：linjx83@mail2.sysu.edu.cn
# @FileName     : m3_adaboost.py
# @Software     : PyCharm

from pro_data import DataSets
from sklearn.ensemble import AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier
from utils.utiils_perf import *

def adaboost_func(data_train, data_test, label_train):

    bdt = AdaBoostClassifier(DecisionTreeClassifier(max_depth=2, min_samples_split=20, min_samples_leaf=5),
                             algorithm="SAMME",
                             n_estimators=600, learning_rate=0.7)
    bdt.fit(data_train, label_train)
    pred_test = bdt.predict(data_test)

    return pred_test

if __name__ == "__main__":
    path_x = "../data/data2_naca0012/dv.csv"
    path_y = "../data/data2_naca0012/fc.csv"

    ds = DataSets(path_x=path_x,
                  path_y=path_y,
                  label_index=2,
                  label_threshold=-0.16,
                  test_proportion=0.1)

    loop_cls(ds, adaboost_func, 2)
